home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3c / drand48.z / drand48
Encoding:
Text File  |  2002-10-03  |  11.0 KB  |  199 lines

  1.  
  2.  
  3.  
  4. ddddrrrraaaannnndddd44448888((((3333CCCC))))                                                        ddddrrrraaaannnndddd44448888((((3333CCCC))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      _dddd_rrrr_aaaa_nnnn_dddd_4444_8888, _eeee_rrrr_aaaa_nnnn_dddd_4444_8888, _llll_rrrr_aaaa_nnnn_dddd_4444_8888, _nnnn_rrrr_aaaa_nnnn_dddd_4444_8888, _mmmm_rrrr_aaaa_nnnn_dddd_4444_8888, _jjjj_rrrr_aaaa_nnnn_dddd_4444_8888, _ssss_rrrr_aaaa_nnnn_dddd_4444_8888, _ssss_eeee_eeee_dddd_4444_8888,
  10.      _llll_cccc_oooo_nnnn_gggg_4444_8888 - generate uniformly distributed pseudo-random numbers
  11.  
  12. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.      _####_iiii_nnnn_cccc_llll_uuuu_dddd_eeee _<<<<_ssss_tttt_dddd_llll_iiii_bbbb_...._hhhh_>>>>
  14.  
  15.      _dddd_oooo_uuuu_bbbb_llll_eeee _dddd_rrrr_aaaa_nnnn_dddd_4444_8888 _((((_vvvv_oooo_iiii_dddd_))))_;;;;
  16.  
  17.      _dddd_oooo_uuuu_bbbb_llll_eeee _eeee_rrrr_aaaa_nnnn_dddd_4444_8888 _((((_uuuu_nnnn_ssss_iiii_gggg_nnnn_eeee_dddd _ssss_hhhh_oooo_rrrr_tttt _xxxx_ssss_uuuu_bbbb_iiii_[[[[_3333_]]]]_))))_;;;;
  18.  
  19.      _llll_oooo_nnnn_gggg _llll_rrrr_aaaa_nnnn_dddd_4444_8888 _((((_vvvv_oooo_iiii_dddd_))))_;;;;
  20.  
  21.      _llll_oooo_nnnn_gggg _nnnn_rrrr_aaaa_nnnn_dddd_4444_8888 _((((_uuuu_nnnn_ssss_iiii_gggg_nnnn_eeee_dddd _ssss_hhhh_oooo_rrrr_tttt _xxxx_ssss_uuuu_bbbb_iiii_[[[[_3333_]]]]_))))_;;;;
  22.  
  23.      _llll_oooo_nnnn_gggg _mmmm_rrrr_aaaa_nnnn_dddd_4444_8888 _((((_vvvv_oooo_iiii_dddd_))))_;;;;
  24.  
  25.      _llll_oooo_nnnn_gggg _jjjj_rrrr_aaaa_nnnn_dddd_4444_8888 _((((_uuuu_nnnn_ssss_iiii_gggg_nnnn_eeee_dddd _ssss_hhhh_oooo_rrrr_tttt _xxxx_ssss_uuuu_bbbb_iiii_[[[[_3333_]]]]_))))_;;;;
  26.  
  27.      _vvvv_oooo_iiii_dddd _ssss_rrrr_aaaa_nnnn_dddd_4444_8888 _((((_llll_oooo_nnnn_gggg _ssss_eeee_eeee_dddd_vvvv_aaaa_llll_))))_;;;;
  28.  
  29.      _uuuu_nnnn_ssss_iiii_gggg_nnnn_eeee_dddd _ssss_hhhh_oooo_rrrr_tttt _****_ssss_eeee_eeee_dddd_4444_8888 _((((_uuuu_nnnn_ssss_iiii_gggg_nnnn_eeee_dddd _ssss_hhhh_oooo_rrrr_tttt _ssss_eeee_eeee_dddd_1111_6666_vvvv_[[[[_3333_]]]]_))))_;;;;
  30.  
  31.      _vvvv_oooo_iiii_dddd _llll_cccc_oooo_nnnn_gggg_4444_8888 _((((_uuuu_nnnn_ssss_iiii_gggg_nnnn_eeee_dddd _ssss_hhhh_oooo_rrrr_tttt _pppp_aaaa_rrrr_aaaa_mmmm_[[[[_7777_]]]]_))))_;;;;
  32.  
  33. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  34.      This family of functions generates pseudo-random numbers using the well-
  35.      known linear congruential algorithm and 48-bit integer arithmetic.
  36.  
  37.      Functions _dddd_rrrr_aaaa_nnnn_dddd_4444_8888 and _eeee_rrrr_aaaa_nnnn_dddd_4444_8888 return non-negative double-precision
  38.      floating-point values uniformly distributed over the interval [0.0,~1.0).
  39.  
  40.      Functions _llll_rrrr_aaaa_nnnn_dddd_4444_8888 and _nnnn_rrrr_aaaa_nnnn_dddd_4444_8888 return non-negative long integers uniformly
  41.      distributed over the
  42.  
  43.      interval [0,~2).
  44.  
  45.      Functions _mmmm_rrrr_aaaa_nnnn_dddd_4444_8888 and _jjjj_rrrr_aaaa_nnnn_dddd_4444_8888 return signed long integers uniformly
  46.      distributed over the interval
  47.  
  48.      [-2,~2).
  49.  
  50.      Functions _ssss_rrrr_aaaa_nnnn_dddd_4444_8888, _ssss_eeee_eeee_dddd_4444_8888, and _llll_cccc_oooo_nnnn_gggg_4444_8888 are initialization entry points,
  51.      one of which should be invoked before either _dddd_rrrr_aaaa_nnnn_dddd_4444_8888, _llll_rrrr_aaaa_nnnn_dddd_4444_8888, or _mmmm_rrrr_aaaa_nnnn_dddd_4444_8888
  52.      is called.  (Although it is not recommended practice, constant default
  53.      initializer values will be supplied automatically if _dddd_rrrr_aaaa_nnnn_dddd_4444_8888, _llll_rrrr_aaaa_nnnn_dddd_4444_8888, or
  54.      _mmmm_rrrr_aaaa_nnnn_dddd_4444_8888 is called without a prior call to an initialization entry point.)
  55.      Functions _eeee_rrrr_aaaa_nnnn_dddd_4444_8888, _nnnn_rrrr_aaaa_nnnn_dddd_4444_8888, and _jjjj_rrrr_aaaa_nnnn_dddd_4444_8888 do not require an initialization
  56.      entry point to be called first.
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. ddddrrrraaaannnndddd44448888((((3333CCCC))))                                                        ddddrrrraaaannnndddd44448888((((3333CCCC))))
  71.  
  72.  
  73.  
  74.      All the routines work by generating a sequence of 48-bit integer values,
  75.      Xi, according to the linear congruential formula
  76.  
  77.                           Xn+1 = (aXn+c)mod m        n_>0.
  78.  
  79.      The parameter m=2 hence 48-bit integer arithmetic is performed.
  80.      Unless _llll_cccc_oooo_nnnn_gggg_4444_8888 has been invoked, the multiplier value a and the addend
  81.      value c are given by
  82.  
  83.            a = 5DEECE66D = 273673163155
  84.            c = B = 13.
  85.  
  86.      The value returned by any of the functions _dddd_rrrr_aaaa_nnnn_dddd_4444_8888, _eeee_rrrr_aaaa_nnnn_dddd_4444_8888, _llll_rrrr_aaaa_nnnn_dddd_4444_8888,
  87.      _nnnn_rrrr_aaaa_nnnn_dddd_4444_8888, _mmmm_rrrr_aaaa_nnnn_dddd_4444_8888, or _jjjj_rrrr_aaaa_nnnn_dddd_4444_8888 is computed by first generating the next
  88.      48-bit Xi in the sequence.  Then the appropriate number of bits,
  89.      according to the type of
  90.      data item to be returned, are copied from the high-order (leftmost) bits
  91.      of Xi and transformed into the returned value.
  92.  
  93.      The functions _dddd_rrrr_aaaa_nnnn_dddd_4444_8888, _llll_rrrr_aaaa_nnnn_dddd_4444_8888, and _mmmm_rrrr_aaaa_nnnn_dddd_4444_8888 store the last 48-bit Xi
  94.      generated in an internal buffer.  Xi must be initialized prior to being
  95.      invoked.  The functions _eeee_rrrr_aaaa_nnnn_dddd_4444_8888, _nnnn_rrrr_aaaa_nnnn_dddd_4444_8888, and _jjjj_rrrr_aaaa_nnnn_dddd_4444_8888 require the calling
  96.      program to provide storage for the successive Xi values in the array
  97.      specified as an argument when the functions are invoked.  These routines
  98.      do not have to be initialized; the calling program must place the desired
  99.      initial value of Xi into the array and pass it as an argument.  By using
  100.      different arguments, functions _eeee_rrrr_aaaa_nnnn_dddd_4444_8888, _nnnn_rrrr_aaaa_nnnn_dddd_4444_8888, and _jjjj_rrrr_aaaa_nnnn_dddd_4444_8888 allow
  101.      separate modules of a large program to generate several _i_n_d_e_p_e_n_d_e_n_t
  102.      streams of pseudo-random numbers, i.e., the sequence of numbers in each
  103.      stream will _n_o_t depend upon how many times the routines have been called
  104.      to generate numbers for the other streams.
  105.  
  106.      The initializer function _ssss_rrrr_aaaa_nnnn_dddd_4444_8888 sets the high-order 32 bits of Xi to the
  107.      32 bits contained in its argument.  The low-order 16 bits of Xi are set
  108.      to the arbitrary value 330E.
  109.  
  110.      The initializer function _ssss_eeee_eeee_dddd_4444_8888 sets the value of Xi to the 48-bit value
  111.      specified in the argument array.  In addition, the previous value of Xi
  112.      is copied into a 48-bit internal buffer, used only by _ssss_eeee_eeee_dddd_4444_8888, and a
  113.      pointer to this buffer is the value returned by _ssss_eeee_eeee_dddd_4444_8888.  This returned
  114.      pointer, which can just be ignored if not needed, is useful if a program
  115.      is to be restarted from a given point at some future time - use the
  116.      pointer to get at and store the last Xi value, and then use this value to
  117.      reinitialize via _ssss_eeee_eeee_dddd_4444_8888 when the program is restarted.
  118.  
  119.      The initialization function _llll_cccc_oooo_nnnn_gggg_4444_8888 allows the user to specify the
  120.      initial Xi, the multiplier value a, and the addend value c.  Argument
  121.      array elements _p_a_r_a_m[_0-_2] specify Xi, _p_a_r_a_m[_3-_5] specify the multiplier
  122.      a, and _p_a_r_a_m[_6] specifies the 16-bit addend c.  After _llll_cccc_oooo_nnnn_gggg_4444_8888 has been
  123.      called, a subsequent call to either _ssss_rrrr_aaaa_nnnn_dddd_4444_8888 or _ssss_eeee_eeee_dddd_4444_8888 will restore the
  124.      ``standard'' multiplier and addend values, a and c, specified on the
  125.      previous page.
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. ddddrrrraaaannnndddd44448888((((3333CCCC))))                                                        ddddrrrraaaannnndddd44448888((((3333CCCC))))
  137.  
  138.  
  139.  
  140. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  141.      _rrrr_aaaa_nnnn_dddd(3C), _rrrr_aaaa_nnnn_dddd_oooo_mmmm(3B)
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.